

#ifndef _CONFIG3_H_
#define _CONFIG3_H_

#include <stdint.h>
#include "config_define.h"

#define CFG_FLAG_UPDATE_KEY 0x01 //密钥更新标志
#define CFG_FLAG_UPDATE_PARAM 0x02 //参数更新标志
/*===================================================================*/
extern config_key_t config_key;
extern config_param_t config_param;
extern const config_key_t cfg_key_default;

// 初始化
int config3_init(void);

// 获取密钥
int config3_get_key(uint8_t id, key_t* key);

//设置密钥
int config3_set_key(uint8_t id, const key_t* key);

// 保存配置
int config3_sync(void);

int config3_update_key(const key_t* key, uint8_t num);

void config3_update(uint8_t flag);

void config3_update_delay(uint32_t ms);

int config3_encrypt(uint8_t* data, uint16_t length, const uint8_t* key);

int config3_decrypt(uint8_t* buffer, uint16_t length, const uint8_t* key);

int config_sam_get_uid(uint8_t* uid);

int config_sam_check_uid(uint8_t* uid, uint8_t ulen);

int config_sam_set_uid(uint8_t* uid, uint8_t ulen);

#endif

